/**
 *
 */
package anyware.common.restlet;

import org.apache.commons.lang.StringUtils;
import org.restlet.Filter;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
/**
 * TODO: doc me
 * 
 * @author keke<keke@codehaus.org>
 * @revision $Revision: 107 $
 * @version
 */
public class VariantFilter extends Filter {
    private static final Logger LOG =
                                      LoggerFactory
                                              .getLogger(VariantFilter.class);

    /*
     * (non-Javadoc)
     * 
     * @see org.restlet.Filter#afterHandle(org.restlet.data.Request,
     *      org.restlet.data.Response)
     */
    @Override
    protected int beforeHandle(final Request request, final Response response) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Before handling : {}", request.getResourceRef());
        }
        final String type = (String) request.getAttributes().get("type");
        if (LOG.isDebugEnabled()) {
            LOG.debug("Type is {}", type);
        }
        if (StringUtils.isEmpty(type)) {
            // TODO:
        } else {
            // final Variant variant = new Variant(MediaType.valueOf(FileTypeMap
            // .getDefaultFileTypeMap().getContentType("file." + type)));
            // request.getAttributes().put("anysware.variantfilter.variant",
            // variant);
        }
        return Filter.CONTINUE;
    }

}
